import type { postOrPutType } from "@/constants";
import type { HasId, IList, IResult } from "@/types/common";
import { getAxios, commonAxiosJson, deleteAxios } from "@/utils/request.js";
const url = "/admin/goods/goods";
/* 获取租机商品列表 */
export const getGoodsList = <T, D>(params?: D): Promise<IResult<IList<T>>> => {
  return getAxios<IList<T>, D>(url, params);
};
/* 获取租机商品详情列表 */
export const getGoodsByIdInfo = <T, D extends HasId>(params: D): Promise<IResult<T>> => {
  return getAxios<T, D>(url + "/" + params.id, params);
};
/* 新增，修改租机商品信息 */
export const commonGoodsInfo = <T, D>(params: D, type: postOrPutType): Promise<IResult<T>> => {
  return commonAxiosJson<T, D>(url, params, type);
};
/* 获取可选的租赁模式 */
export const getGoodsOrderRentTypeList = <T, D>(params?: D): Promise<IResult<T>> => {
  return getAxios<T, D>(url + "/order-rent-type", params);
};
/* 同步商品到抖音库 */
export const putSyncDouyinProductInfo = <T, D>(params: D): Promise<IResult<T>> => {
  return commonAxiosJson<T, D>(url + "/save-douyin-product", params, "PUT");
};
/* 对抖音商品进行上下架(只有已同步商品才能进行操作) */
export const putOperateDouyinProductInfo = <T, D>(params: D): Promise<IResult<T>> => {
  return commonAxiosJson<T, D>(url + "/operate-douyin-product", params, "PUT");
};
/* 同步抖音商品状态 */
export const putSyncDouyinGoodsStatusInfo = <T, D>(params: D): Promise<IResult<T>> => {
  return commonAxiosJson<T, D>(url + "/sync-douyin-goods-status", params, "PUT");
};
/* 同步商品到支付宝 */
export const putSyncAliGoodsInfo = <T, D>(params: D): Promise<IResult<T>> => {
  return commonAxiosJson<T, D>(url + "/sync-ali-goods", params, "PUT");
};
/* 对支付宝商品进行上下架(只有已同步商品才能进行操作)  */
export const putSyncAliGoodsStatusInfo = <T, D>(params: D): Promise<IResult<T>> => {
  return commonAxiosJson<T, D>(url + "/sync-ali-goods-status", params, "PUT");
};
/* 修改商品上下架状态 */
export const putUpdateIsOnSaleInfo = <T, D>(params: D): Promise<IResult<T>> => {
  return commonAxiosJson<T, D>(url + "/update-is-on-sale", params, "PUT");
};
/* 删除 租机商品信息 */
export const deleteGoodsInfo = <T, D>(params: D): Promise<IResult<T>> => {
  return deleteAxios<T, D>(url, params);
};
